package com.sinaapp.kjWeb.service;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.sinaapp.kjWeb.Schedule.AtuoSchedule;
import com.sinaapp.kjWeb.dao.KjEmployDao;
import com.sinaapp.kjWeb.pojo.KaiJieUser;

/*
 *auth:徐疆
 *date 2014-1-23 下午9:28:01
 */
@Service("kjEmployService")
public class KjEmployService {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger
			.getLogger(KjEmployService.class);

	@Resource(name="kjEmployDao")
	private KjEmployDao dao;
	
	@Resource(name="atuoSchedule")
	private AtuoSchedule atuoSchedule;
	/**
	 * 根据员工ID设置员工自动签到
	 * @param employId
	 * @return
	 */
	public boolean updateAutoCheck(KaiJieUser kju){
		logger.info("updateAutoCheck==========="+kju);
		boolean t= dao.update(kju)==1;
		//新添加的人员 ，添加到任务队列中
		if(t){
			atuoSchedule.addAtuoTask(kju);
		}
		return t;
	}
	
	public List<KaiJieUser> getAllAtuoUser(){
		return dao.getAllAtuoUser();
	}
	/**
	 * 根据员工ID设置员工停止自动签到
	 * @param employId
	 * @return
	 */
	public boolean updatePauseCheck(String employId){
		KaiJieUser kju=new KaiJieUser();
		kju.setEmployID(employId);
		kju.setAutoCheck(0);
		return dao.update(kju)==1;
	}
	
	
}

